-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add tag to log api #92
Conversation
|
||
export async function POST( | ||
req: Request, | ||
{ params }: { params: { id: string } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice for readability for this to be typed outside e.g type QueryParams = { id : string }
and then you could us it like { params : QueryParams}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but maybe thats just my preference :P
req: Request, | ||
{ params }: { params: { id: string } }, | ||
) { | ||
const json = await req.json(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can .json
here throw? What happens?
{ params }: { params: { id: string } }, | ||
) { | ||
const json = await req.json(); | ||
const tagId = json.tagId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const tagId = json.tagId; | |
const { tagId } = json; |
const json = await req.json(); | ||
const tagId = json.tagId; | ||
try { | ||
await LogsData.connectTag(params.id, tagId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while to work out what this meant - naming is tough :( Perhaps being more explicit with something like connectTagToLog
is worth it? Not sure
try { | ||
await LogsData.connectTag(params.id, tagId); | ||
} catch (error) { | ||
return NextResponse.json({ error: error }, { status: 500 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't catch it, would this not be the default behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it only return a response with status 500, but no error message. It doesn't seem like an error message shows in the console either.
https://trello.com/c/gaGfCBt8/267-2-aadev-when-i-make-an-api-call-to-link-an-existing-tag-with-a-log-i-can-see-it-in-the-database